package cn.liit.weixin.templatemsg.support;

import java.util.Map;

import cn.liit.weixin.templatemsg.utils.MsgUtil;

public class TemplateMsgThread extends Thread{
	private long millis;//线程停止时间
	private String accessToken;
	private String openid;
	private String url;
	private String templateid;//模板消息id
	private String first;//内容标题
	private String[] keywrods;//内容关键字数组，keyword1,keyword2...keywordn
	private String remark;//底部备注信息
	
	public TemplateMsgThread(String accessToken, String openid, String url, String templateid,
			String first, String[] keywrods, String remark, long millis) {
		super();
		this.millis = millis;
		this.accessToken = accessToken;
		this.openid = openid;
		this.url = url;
		this.templateid = templateid;
		this.first = first;
		this.keywrods = keywrods;
		this.remark = remark;
	}

	@Override
	public void run() {
		try {
			Thread.currentThread().sleep(millis);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		Map<String,String> result = MsgUtil.sendTemplateMsg(accessToken, openid, url, templateid, first, keywrods, remark);
		System.out.println(result);
	}
	public static void main(String[] args) {
		new TemplateMsgThread("DOYoBMpXsOOTxR4Nq4l9YHY2rFWNy4aEQ4-dih0VDb2gWHG8S1dSgLHEi3WTEOjX01d91B3Mnnlqu7Er1-pjA6cjhLJd3aUcvxLzEF-Ttf8VEMgABAMVD",
				"okyoyuHLHcY5z1JCq1guLBbQO4JI", 
				"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx7bb792d21a4feb60&redirect_uri=http%3A%2F%2Fm.1yuanbao.net%2FRegData%2FwithoutLoginAuthorization.do&response_type=code&scope=snsapi_base&state=menu33#wechat_redirect",
				"50XV-3XD9tVdOoZLLqBYOhYJoaEwhcrkJJ5RFe15KkU", 
				"尊敬的一元宝用户,恭喜您获得本期参与商品", new String[]{"一元宝","科奈信（Cannice）Y2无线蓝牙耳机 运动跑步立体声超长待机通用双耳后挂式音乐耳机"},
				"点击查看详情", 8000).start();
	}

	public long getMillis() {
		return millis;
	}

	public void setMillis(long millis) {
		this.millis = millis;
	}

	public String getAccessToken() {
		return accessToken;
	}

	public void setAccessToken(String accessToken) {
		this.accessToken = accessToken;
	}

	public String getOpenid() {
		return openid;
	}

	public void setOpenid(String openid) {
		this.openid = openid;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getTemplateid() {
		return templateid;
	}

	public void setTemplateid(String templateid) {
		this.templateid = templateid;
	}

	public String[] getKeywrods() {
		return keywrods;
	}

	public void setKeywrods(String[] keywrods) {
		this.keywrods = keywrods;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
	
}
